#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

// set NOISY_TEST to 0 to remove printfs from output
#define NOISY_TEST 1

int main() {

	// based off of testUpdateCoins  example provided for class
    int i;
    int seed = 1000;
    int numPlayer = 2;
    //int maxBonus = 10;
    //int p, r, handCount;
	int r;
    int bonus;
    int k[10] = {adventurer, council_room, feast, gardens, mine
               , remodel, smithy, village, baron, great_hall};
    struct gameState G;
    //int maxHandCount = 5;
	
	//card effect values
	int choice1 = 1;
	int choice2 = 0;
	int choice3 = 0;
	int handPos = 0;
	int test = 0;
	int passed = 0;
	
	//int testHandCount;
	int numBuys;
	int numCoins;
	int numEstate;
	
	memset(&G, 23, sizeof(struct gameState));   // clear the game state
	r = initializeGame(numPlayer, k, seed, &G); // initialize a new game
	i = G.whoseTurn; // check which player is up;
	numEstate = G.supplyCount[estate];
	
	numBuys = G.numBuys + 1; //set initial hand count
	numCoins = G.coins + 4; //set initial hand count
	
	test = cardEffect(baron, choice1, choice2, choice3, &G, handPos, &bonus);
	if(test == -1){
		passed = 1;
		printf("cardtest2: FAIL - baron, card effect return -1!\n");
	}
	
	//test numBuys is increased
	if(numBuys != G.numBuys ){
		passed = 1;
		printf("cardtest2: FAIL - baron, numBuys not increased!\n");
	}
	
		//test coins increased
	if(numCoins != G.coins ){
		passed = 1;
		printf("cardtest2: FAIL - baron, coins not increased!\n");
	}
	
	if(numEstate != G.supplyCount[estate] ){
		passed = 1;
		printf("cardtest2: FAIL - baron, estates count not correct!\n");
	}
	
	choice1 = 0;
	test = cardEffect(baron, choice1, choice2, choice3, &G, handPos, &bonus);
	if(test == -1){
		passed = 1;
		printf("cardtest2: FAIL - baron, card effect return -1!\n");
	}
	numEstate--;
	if(numEstate != G.supplyCount[estate] ){
		passed = 1;
		printf("cardtest2: FAIL - baron, estates supply count not correct!\n");
		//printf("%i XX %i\n", numEstate, G.supplyCount[estate]);
	}
	
	if(G.discard[0][0] != estate){
		passed = 1;
		printf("cardtest2: FAIL - baron, estates not in discard!\n");
	}
	
	if(passed == 0){
		printf("cardtest2: baron - All tests passed!\n");
	}

    return 0;
}